import tkinter as tk
from PIL import Image, ImageTk
import os


def execute_first_file():
    os.system("python realtime.py")


def execute_second_file():
    os.system("python bendi.py")


root = tk.Tk()
root.title("俯卧撑计数器")

background_image = Image.open("background.png")
background_image = ImageTk.PhotoImage(background_image)

window_width = 600
window_height = 400
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_coordinate = (screen_width - window_width) // 2
y_coordinate = (screen_height - window_height) // 2

root.geometry(f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}")

background_label = tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)

title_font = ("楷体", 40)
title_label = tk.Label(root, text="俯卧撑计数器", font=title_font, bg='lightyellow')
title_label.place(relx=0.5, rely=0.2, anchor="center")

button_font = ("楷体", 18)
button1 = tk.Button(root, text="实时计数", command=execute_first_file, font=button_font, bg="lightblue", padx=20,
                    pady=10)
button1.place(relx=0.5, rely=0.5, anchor="center")

button2 = tk.Button(root, text="视频计数", command=execute_second_file, font=button_font, bg="lightgreen", padx=20,
                    pady=10)
button2.place(relx=0.5, rely=0.7, anchor="center")

root.mainloop()
